#include "cmd_input.h"
#include"other.h"
#include<iostream>
std::vector<std::string> cmd_input::one_line_input()
{
    std::vector<std::string> res_vector;
    while (res_vector.empty())
    {
        std::string str;
        std::getline(std::cin, str);
        str = trim(str);
        res_vector = split(str, ' ');
    }
    return res_vector;
}
std::string cmd_input::input()
{
    std::string res = "";
    while (res.empty())
    {
        std::vector<std::string> res_vector=one_line_input();
        if (res_vector[0] == "MULTI") {
            res_vector.clear();
            res_vector.push_back("MULTI");
            std::vector<std::string> tmp_vec;
            tmp_vec = one_line_input();
            while (tmp_vec[0]!="END")
            {
                std::size_t len = tmp_vec.size();
                res_vector.push_back(convert<std::string>(len));
                res_vector.insert(res_vector.end(), tmp_vec.begin(),tmp_vec.end());
                tmp_vec = one_line_input();
            }
        }
        res = join(res_vector, ' ');
    }
    return res;
}

void cmd_input::output(const std::string& str)
{
    std::cout << str;
}
